﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;

namespace VSDebugTutorial
{
    class Program
    {
        static void Main()
        {
            Console.Read(); //This is demo for remote debugging.

            int temp = 4;
            for (int i = 1; i <= 10; i++)
            {
                if (i > 6)
                    temp = 5;// Run to Cursor Ctrl+F10
                Console.WriteLine(temp.ToString(CultureInfo.CurrentCulture));
            }



            BreakConditionalTest();

            BreakHitCountTest();


        }

        #region General Debug Method

        /// <summary>
        /// Demo to show the conditional breakpoint feature.
        /// </summary>
        static void BreakConditionalTest()
        {

            string[] strNames = { "Name1", "Name2", "Name3", "Name4", "Name5", "Name6" };

            foreach (string name in strNames)
            {
                Console.WriteLine(name);
            }
        }


        /// <summary>
        /// Demo to show the break hit count feature.
        /// </summary>
        static void BreakHitCountTest()
        {
            for (int i = 0; i < 100; i++)
            { //Break when hit count bigger or equal than 51, that is when i >=50.
                Console.WriteLine(i.ToString(CultureInfo.CurrentCulture));
                System.Diagnostics.Trace.WriteLine(String.Format(CultureInfo.CurrentCulture, "Currently the i is {0}.", i.ToString(CultureInfo.CurrentCulture)));

            }
        }

        #endregion 


        #region Windbg

        /// <summary>
        /// High CPU
        /// </summary>
        public static void GenerateHighCPU()
        {
            new Thread(() =>
            {
                while (true)
                {
                }
            }).Start();
        }


        /// <summary>
        /// High Memory
        /// </summary>
        public static void GenerateHighMemory()
        {
            List<Byte[]> list = new List<byte[]>();

            for (int i = 0; i < 10; i++)
            {
                list.Add(new byte[1024 * 1024 * 10]);
            }
        }

        #endregion 



    }

}
